<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>管理</a>
        <a>
          <cite>沟通记录管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so layui-form-pane">
            <div class="layui-input-inline">
                <input type="text"  style="width: 200px;" name="day" id="date" placeholder="选择跟进日期" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline">
                <button class="layui-btn" id="search">
                    <i class="layui-icon layui-icon-search"></i>筛选</button>
                <button class="layui-btn layui-btn-danger" id="clear">
                    <i class="layui-icon"></i>重置</button>

            </div>
        </div>
    </div>
    <blockquote id="kehuguanli" class="layui-elem-quote">
        沟通记录管理
    </blockquote>
    <table class="layui-table" id="datalist" lay-filter="Event"></table>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['table', 'element', 'laydate', 'layer'], function () {
        let table = layui.table,
            laydate = layui.laydate,
            element = layui.element,
            layer = layui.layer,
            $ = layui.$;

        //限定可选日期
        laydate.render({
            elem: '#date'
            // ,max: day_date
            ,range: true
            ,trigger: 'click'
        });
        let loading = layer.load();
        //方法级渲染
        let tableIns = table.render({
            elem: '#datalist'
            , url: '{:url("Administration/customer_follow_up_list")}'
            , method: 'POST'
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'id', title: 'ID',width: 100, sort: true, fixed: false},
                {field: 'name', title: '书店名称',width: 200, style:'color:#01AAED;font-weight: bold;',  align: 'center', event: 'setSign'},
                {field: 'phone', title: '联系方式',width: 150,align: 'center'},
                {field: 'remark', title: '内容', minWidth: 300, align: 'center'},
                {field: 'date', title: '跟进日期',width: 150, align: 'center'},
                {field: 'user_name', title: '跟进人',width: 200, align: 'center'},
            ]]
            , page: true
            , done: function () {
                // $("[data-field='id']").css('display','none');
                layer.close(loading);
            }
        });

        //监听单元格事件
        table.on('tool(Event)', function (obj) {
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'setSign'){
                layer.open({
                    type: 2,
                    skin: 'layui-layer-lan',
                    closeBtn: 2,
                    title: '客户详情',
                    area: ['80%', '80%'],
                    shadeClose: false,
                    content: "{:url('Customer/information')}?id=" + data.student_id + "&status="+1
                });
            }
        });

        //搜索项
        $('#search').click(function () {
            let field = {};
            field.day = $('input[name=day]').val();
            tableIns.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#clear').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[name=day]').val('');
            })
            tableIns.reload({
                where: {
                    'day': ''
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
    });
</script>